<?php
//ob_start();
include_once "header.php";

$daftar_tujuan = new Daftar_tujuan_surat();
$tujuan = $daftar_tujuan->getPengirimanSK();

?>

<div id="container">
	<div id="maincont">
		<?php include_once "menu_samping.php"; ?>
		<div id="mainright">
			<div id="title">
			Pengiriman Surat Keluar
			</div>
			<div id="body"
			<br>
			<form name="form1" method="POST" action="ekspedisi_sk.php">			
			<table id="table2" cellspacing=0 cellpadding=4 width=100%>
				<tr>
					<th width=3%></th>
					<th>No. Surat</th>
					<th width=8%>Tgl. Surat</th>
					<th width=5%>Sifat</th>
					<th width=25%>Tujuan</th>
					<th width=5%>Jenis Tujuan</th>
					<th width=5%>Status Kirim</th>
					<th width=5%>Bukti Kirim</th>
					<th width=8%>Tanggal Kirim</th>
					<th width=8%>Kurir</th>
					
					<th width=5%></th>
				</tr>
				
				<?php
				$i=1;
				foreach($tujuan as $Tujuan){	
				$daftar_sk = new Daftar_surat_keluar();
				$sk = $daftar_sk->getById($Tujuan->getKdSK());
				?>
				<tr>
				<td>
				<input type="checkbox" value="<?php echo $Tujuan->getId(); ?>" name="<?php echo "tujuan_sk[]"; ?>" />
				</td>
				
				
				<td>
				<?php
					$daftar_jenis = new Daftar_jenis();
					$jenis = $daftar_jenis->getById($sk->getJenis());
					echo ucwords($jenis->getJenis())."-".$sk->getNomor();
				?>
				
				</td>
								
				<td>
				<?php
				echo $sk->getTgl();
				?>
				</td>
				
				
				<td>
				<?php
					$daftar_sifat = new Daftar_sifat_surat();
					$sifat = $daftar_sifat->getById($sk->getSifat());
					echo ucwords($sifat->getSifat());
				?>
				
				</td>
				
				
				<td>
				<?php
					echo $Tujuan->getTujuan();
				?>
				</td>
				
				<td>
				<?php
					echo ucwords($Tujuan->getJenisTujuan());
				?>
				</td>
				
				<td>
				<?php
					if($Tujuan->getTerkirim()==0){
					echo "<img src=\"images/Button-warning-icon.png\" width=15px height=15px/>";}
					
					if($Tujuan->getTerkirim()==1){
					echo "<img src=\"images/ok-icon.png\" width=15px height=15px/>";}
				?>
				</td>
				
				<td >
				<?php
					if($Tujuan->getBuktiKirim()!="" || $Tujuan->getBuktiKirim()!=0){
						//echo "<a href=\"bukti_kirim.php?id_tuj=".$Tujuan->getId()."\" target=\"_BLANK\"><img src=\"images/attachment.png\" width=25px height=20px/></a>";
						echo "<a href=\"images/bukti_kirim/".$Tujuan->getBuktiKirim()."\"
						onclick=\"window.open('images/bukti_kirim/".$Tujuan->getBuktiKirim()."','popup',
						width=410, height=200, scrollbars=no, resizable=no, toolbar=no,directories=no, 
						location=no, menubar=no, status=no, left=0, top=0');\" target=\"_blank\">
						<img src=\"images/attachment.png\" width=20px height=15px/>
						</a>";
					}					
					
				?>
				</td>
				
				<td>
				<?php
					$tgl_kirim = $Tujuan->getTglKirim();
					if($tgl_kirim!="0000-00-00"){
						echo $tgl_kirim;
					}
				?>
				</td>
				
				<td>
				<?php
				
					$daftar_kurir = new Daftar_kurir();
					if($Tujuan->getKurir() != 0){
						$kurir = $daftar_kurir->getById($Tujuan->getKurir());
						echo ucwords($kurir->getKurir());
					}
				?>
				</td>
				
				<td>
				<a href="ubah_status_pengiriman.php?id_tuj=<?php echo $Tujuan->getId(); ?>" alt="ubah" title="ubah"><img src="images/Text-Edit-icon.png" width=15px height=15px/></a>
				</td>
			</tr>
				<?php $i++;} ?>
			</table>
			<?php
			if(empty($tujuan)){
				echo "<table cellspacing=0 cellpadding=4 width=100%>";
				echo "<tr>";
				echo "<td>";
					echo "Data tidak tersedia.";	
				echo "</td>";			
				echo "</tr>";
				echo "</table>";
			}
			?>
			<br>
			<input type="submit" value="Cetak">
			</form>		
			</div>
        </div>
	</div>
</div>
<?php
	include_once "footer.php";
?>

<script type="text/javascript">
	function del(){
	if(confirm('Apakah Anda yakin akan menghapus surat ini?'))
	return true;
	else return false
	}
</script>
